<?php

class myUser extends sfBasicSecurityUser
{
  public function signIn($user)
  {
    $this->setAuthenticated(true);    
    $this->addCredential($user->getCredential());

    $this->setAttribute('id', $user->getId(), 'subscriber');
    $this->setAttribute('name', $user->getName(), 'subscriber');
    $this->setAttribute('username', $user->getUsername(), 'subscriber');
    
    $this->setDirection();     
  }
  
  public function setDirection()
  {
  	$language = LanguagePeer::retrieveByCulture($this->getCulture());
    $this->setAttribute('direction', $language->getDir(), 'subscriber');
  }
  
  public function getDirection()
  {
  	return $this->getAttribute('direction', null, 'subscriber');
  }
  
  /**
   * Logs user out of the system
   *
   * Destroys user session and cookies
   *
   * @return void
   */  
  public function signOut()
  {    
    $this->getAttributeHolder()->removeNamespace('subscriber');
 
    $this->setAuthenticated(false);
    $this->clearCredentials();
  }  
  
  public function getLang()
  {
  	return myTools::langFromCulture($this->getCulture());
  }
  
  public function getId()
  {
  	return $this->getAttribute('id', null, 'subscriber');
  }
  
  public function getName()
  {
  	return $this->getAttribute('name', null, 'subscriber');
  }
  
  public function getUsername()
  {
  	return $this->getAttribute('username', null, 'subscriber');
  }
}
